import axios from '@/utils/axios'

export const getRole = (id: string): Promise<ApiResult<BaseRole>> => {
    return axios.get(`base/role/${id}`)
}

export const getRoleList = (): Promise<ApiResult<Array<BaseRole>>> => {
    return axios.get(`base/role/list`)
}

export const getRolePage = (pagination: Pagination, params: BaseRole): Promise<ApiResult<Page<BaseRoleVO>>> => {
    return axios.get(`base/role/page/${pagination.page}/${pagination.pageSize}`, { params })
}

export const postOrPutRole = (data: BaseRole): Promise<ApiResult<null>> => {
    return axios.post(`base/role`, data)
}

export const deleteRole = (id: string): Promise<ApiResult<null>> => {
    return axios.delete(`base/role/${id}`)
}

export const getRoleListByUserId = (userId: string): Promise<ApiResult<Array<BaseRole>>> => {
    return axios.get(`base/role/listByUserId/${userId}`)
}
